package org.wedding.center.controller;

import org.wedding.center.entity.RightInfo;
import org.wedding.center.service.RightInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.wedding.utils.CommonResult;
import org.wedding.dto.PageModel;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限信息表(RightInfo)表控制层
 *
 * @author songkaiyue
 * @since 2025-05-21 14:18:02
 */
@AllArgsConstructor
@RestController
@RequestMapping("/rightInfo")
@Tag(name = "RightInfo", description = "权限信息表")
public class RightInfoController{
    private final RightInfoService rightInfoService;
    
    
    /**
     * 分页查询所有数据
     *
     * @param query 分页对象
     * @return 所有数据
     */
    @Operation(summary = "分页查询所有数据")
    @RequestMapping(value = "/list", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult<PageModel> list(PageModel query) {
        return rightInfoService.findAll(query);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @Operation(summary = "通过主键查询单条数据")
    @RequestMapping(value = "/view", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult view(String id) {
        return rightInfoService.view(id);
    }

    /**
     * 查询全平台唯一一条权限数据
     * @return
     */
    @Operation(summary = "查询全平台唯一一条权限数据")
    @RequestMapping(value = "/findOne", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult findOne() {
        return rightInfoService.findOne();
    }

    /**
     * 新增数据
     *
     * @param rightInfo 实体对象
     * @return 新增结果
     */
    @Operation(summary = "新增数据")
    @RequestMapping(value = "/add", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult add(@RequestBody RightInfo rightInfo) {
        return rightInfoService.add(rightInfo);
    }

    /**
     * 修改数据
     *
     * @param rightInfo 实体对象
     * @return 修改结果
     */
    @Operation(summary = "修改数据")
    @RequestMapping(value = "/update", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult update(@RequestBody RightInfo rightInfo) {
        return rightInfoService.updateEntity(rightInfo);
    }

   /**
     * 删除数据
     *
     * @param ids 主键
     * @return 删除结果
     */
    @Operation(summary = "删除数据")
    @RequestMapping(value = "/delete", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult delete(@RequestBody List<String> ids) {
        return rightInfoService.delete(ids);
    }
    
}

